﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Centrica.Task.Model
{
    /// <summary>
    /// 
    /// </summary>
    public abstract class TaskFactory<T> where T : TaskFactory<T>, new()
    {
        private static T _instance = null;

        /// <summary>
        /// 
        /// </summary>
        protected TaskFactory()
        {
        }

        public virtual T CreatestaticProviderInstance()
        {
            return null;
        }

        /// <summary>
        /// 
        /// </summary>
        public static TaskFactory<T> staticProviderInstance
        {
            get
            {
                if (TaskFactory<T>._instance == null)
                {
                    TaskFactory<T>._instance = new T().CreatestaticProviderInstance();
                }
                return TaskFactory<T>._instance;
            }
        }

        public List<Task> GetAllTasks()
        {
            return new List<Task>();
        }

        public List<Task> GetByTemplate(Task template)
        {
            return new List<Task>();
        }
    }

    /// <summary>
    /// 
    /// </summary>
    public enum TaskStatus
    {
        None,
        Unauthorised,
        Initiated,
        InProgress,
        Completed
    }

    /// <summary>
    /// 
    /// </summary>
    public class Task
    {
        /// <summary>
        /// 
        /// </summary>
        protected Task()
        {
            this.ID = Guid.NewGuid();
            this.Status = TaskStatus.None;
        }

        /// <summary>
        /// 
        /// </summary>
        public static Task CreateInstance()
        {
            return new Task();
        }

        public static Task CreateInstance(Task instance)
        {
            return new Task()
            {
                ID = Guid.NewGuid(),
                Name = instance.Name,
                Status = instance.Status,
                Description = instance.Description,
                StartDate = instance.StartDate,
                FinishDate = instance.FinishDate,
                Owner = instance.Owner
            };
        }

        /// <summary>
        /// 
        /// </summary>
        public Guid ID
        {
            get;
            set;
        }

        public String Name
        {
            get;
            set;
        }

        public TaskStatus Status
        {
            get;
            set;
        }

        public String Description
        {
            get;
            set;
        }

        public DateTime StartDate
        {
            get;
            set;
        }

        public DateTime FinishDate
        {
            get;
            set;
        }

        public String Owner
        {
            get;
            set;
        }
    }
}
